
PACKAGE BODY Test_Cases_Mainsuite IS


   -- Initialisation du lanceur de test
   PROCEDURE Set_Up IS
   BEGIN
      nbTest := (OTHERS => -1);
      nbError := (OTHERS => -1);
      names := (OTHERS => Dyn_Str.To_Unbounded_String(""));
   END Set_Up;


   -- Lancement des suites de tests
   PROCEDURE Run IS
   BEGIN

      -- Tests de robustesse du parser XML
      Test_Parser.Set_Up;
      Test_Parser.Run;
      Test_Parser.Tear_Down(nbTest(1), nbError(1), names(1));

      -- Tests de validite des fonctions du reseau de Petri
      Test_Cases_Petrinet.Set_Up;
      Test_Cases_Petrinet.Run;
      Test_Cases_Petrinet.Tear_Down(nbTest(2), nbError(2), names(2));

      -- Tests de validite des proprietes des reseaux de Petri
      Test_Properties.Set_Up;
      Test_Properties.Run;
      Test_Properties.Tear_Down(nbTest(3), nbError(3), names(3));

   END Run;


   -- Terminaison du lanceur de test
   PROCEDURE Tear_Down IS
      errors : Integer := 0;
      tests : Integer := 0;
      PACKAGE Integerio IS NEW Ada.Text_IO.Integer_Io (Integer);
   BEGIN

      -- Affichage des rapport pour chaque suites
      FOR i IN 1..Nombre_De_Suites LOOP
         IF nbError(i) = -1 THEN
            RAISE Test_Error;
         END IF;
         IF nbError(i) = 0 THEN
            Ada.Text_IO.Put_Line ("--> Suite """ & Dyn_Str.To_String(names(i)) & """ OK ");
         ELSE
            Ada.Text_IO.Put_Line ("/!\ Suite """ & Dyn_Str.To_String(names(i)) & """ KO");
            Ada.Text_IO.Put ("-->");
            Integerio.put(nbError(i));
            errors := errors + nbError(i);
            Ada.Text_IO.Put_Line (" Erreur");
         END IF;
         Ada.Text_IO.Put ("-->");
         Integerio.put(nbTest(i));
         tests := tests + nbTest(i);
           Ada.Text_IO.Put_Line (" Tests");
         Ada.Text_IO.New_Line;
      END LOOP;


      -- Affichage du rapport pour l'ensemble de l'application
      Ada.Text_IO.Put_Line("----------------------------------");
      IF errors = 0 THEN
         Ada.Text_IO.Put_Line ("--> Test de l'application :  OK ");
      ELSE
         Ada.Text_IO.Put_Line ("/!\ Test de l'application :  KO !");
         Ada.Text_IO.Put ("-->");
         Integerio.put(errors);
         Ada.Text_IO.Put_Line (" Erreur");
      END IF;
      Ada.Text_IO.Put ("-->");
      Integerio.put(tests);
      Ada.Text_IO.Put_Line (" Tests");
      Ada.Text_IO.Put_Line ("----------------------------------");
      Ada.Text_IO.New_Line;
   END Tear_Down;

END Test_Cases_Mainsuite;
